#define _CRT_SECURE_NO_WARNINGS 1
#include <climits>
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n = 0, aim = 0;
    cin >> n >> aim;
    cerr << "n=" << n << ",aim=" << aim << endl;
    vector<int> arr(n + 1, 0);
    for (int i = 1;i <= n;i++)
    {
        cin >> arr[i];
        cerr << arr[i] << " ";
    }
    cerr << endl;
    vector<vector<int>> dp(n + 1, vector<int>(aim + 1, INT_MAX));
    for (int i = 0;i <= n;i++) dp[i][0] = 0;
    for (int i = 1;i <= n;i++)
    {
        cerr << "i=" << i << endl;
        for (int j = 0;j <= aim;j++)
        {
            //cerr<<"|j="<<j<<", ";
            int x = dp[i - 1][j];
            int y = INT_MAX;
            if (j - arr[i] >= 0 && dp[i][j - arr[i]] != INT_MAX)
            {
                y = dp[i][j - arr[i]] + 1;
            }
            //cerr<<"x="<<x<<",y="<<y;
            dp[i][j] = min(x, y);
        }
        //cerr<<endl;
    }
    if (dp[n][aim] == INT_MAX) cout << "-1" << endl;
    else cout << dp[n][aim] << endl;
    cerr << dp[n][aim] << endl;
    return 0;
}
